package edu.sctu.alex.projectPratice.subwaysystem.until;

import edu.sctu.alex.projectPratice.subwaysystem.appbean.PeopleAppbean;
import edu.sctu.alex.projectPratice.subwaysystem.data.SetPeopleData;
import edu.sctu.alex.projectPratice.subwaysystem.data.SetTrainData;


import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;


/**
 * Created by user03 on 2015/6/5.
 */
public class TimeTable {

    public Calendar getUseTime() {
        return useTime;
    }

    public void setUseTime(Calendar useTime) {
        this.useTime = useTime;
    }

    private Calendar useTime;

    Calendar calendar = Calendar.getInstance();

    public void gainBeginTime(){

        setUseTime(calendar);
        System.out.println("进站时间:"+getUseTime().getTime());


    }

    /**
     * 每个站 用时两分钟
     */
    public void gainEndTime(){
        PeopleAppbean p = new SetPeopleData().setPeopleData().get(0);
        SetTrainData train  = new SetTrainData();
        HashMap<String,Integer> map ;
        map  = train.setHashMapData();
        int count = 0;
        count =  ((map.get(p.getEndStation())) -  (map.get(p.getStarStation())))*2;

        if (train.setProblem()) {

            System.out.println("列车出现问题，停止运行！！！");
        }else {

            getUseTime().add(Calendar.MINUTE, count);

            System.out.println("出战时间:" + getUseTime().getTime());
        }
    }

    public void testString(){

        String time = "2015-06-09 20:30:00";

        SimpleDateFormat simple =  new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        Date date = null;


            try {
                date = simple.parse(time);
            } catch (ParseException e) {
                e.printStackTrace();
            }

        System.out.println(simple.format(date));
    }

}
